package com.webkitlib.util;

import java.util.Calendar;

import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

/**
 * 
 * 点击事件做延迟，配合涟漪使用
 * 
 * @author 韩伟光
 * @version 1.0
 * @since 2016-1-29
 */
public abstract class KNoDoubleItemClickListener implements OnItemClickListener {
    public static final int MIN_CLICK_DELAY_TIME = 800; // 延时的时间
    private long lastClickTime = 0;
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        /* 判断上次点击和这个点击时间要大于延时时间，这样就不会两次进入同一个界面了 */
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onNoDoubleItemClick(view, position, id);
        }
    }

    public abstract void onNoDoubleItemClick(View v, int position, long id);
}
